#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for(register int i = (a);i <= (b);++i)
#define per(i,a,b) for(register int i = (a);i >= (b);--i) 
#define mkp std::make_pair
typedef long long ll;
typedef unsigned long long ull;
using std::string;using std::cin;using std::cout;
inline bool cmp(int x,int y){return x < y;}

const int N = 1e6+9;
const int inf = 1e9+9;
const double eps = 1e-7;
int _,n,m,a[2*N],p,now,tmp;
ll ans,st[1100],w[1100],S,h[1100][1100];
char ch[1100];
bool map[1100][1100];

int main(){
    std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef LOCAL //use "g++ xxx.cpp -DLOCAL"
        freopen("in.in", "r", stdin);
    #endif
    cin >> n >> m;
    rep(i,1,n){
        cin >> ch+1;
        rep(j,1,m) map[i][j] = (ch[j] == '.');
    }

    per(i,n,1) rep(j,1,m) if(map[i][j]) h[i][j] = h[i+1][j]+1;

    rep(line,1,n){
        std::memset(w,0,sizeof(w));
        std::memset(st,0,sizeof(st));
        p = S = 0;
        rep(i,1,m){
            now = h[line][i] , tmp = 0;
            if(!now){p=S=0,w[1] = w[0] = 0;continue;}
            while(now <= st[p]) S -= (st[p]-now)*w[p] , tmp += w[p--];
            st[++p] = now , w[p] = tmp+1 , S += now;
            ans += S;            
        }    
    }
    cout << ans << "\n";
    return 0;
}